const path = require('path');
const UglifyPlugin = require('uglifyjs-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
    entry: './src/index.js',
    module: {
        rules: [
            {
                test: /\.jsx$/,
                include: [
                    path.resolve(__dirname, 'src')
                ],
                use: 'babel-loader',
            },
            {
                test: /\.css/,
                include: [path.resolve(__dirname, 'src'),
                ],
                use: ExtractTextPlugin.extract({
                    fallback:'style-loader',
                    use:  'css-loader',
                }),
            },
            {
                test: /\.(png|jpg|gif)$/,
                use: {
                    loader: "file-loader",
                    options:{},
                },
            },
        ],
    },
    resolve: {
        modules: [
            "node_modules",
            path.resolve(__dirname, 'src')
        ],
        extensions: [".wasm", "mjs", ".js", ".json", ".jsx"],
    },
    plugins: [
        new UglifyPlugin(),
        new HtmlWebpackPlugin({
        filename: "index.html",
        template: "public/index.html"
    }),
        new ExtractTextPlugin('index.css'),
    ]
}
